home *** CD-ROM | disk | FTP | other *** search
- program TstStrms;
-
- {$APPTYPE CONSOLE}
-
- uses
- SysUtils,
- Classes,
- AAStrms;
-
- var
- FSIn : TFileStream;
- FSOut : TFileStream;
- BFIn : TaaReadBufferFilter;
- BFOut : TaaWriteBufferFilter;
- TFIn : TaaReadTextFilter;
- TFOut : TaaWriteTextFilter;
- RFIn : TaaRegexTextFilter;
- Debug : TaaDebugFilter;
- WFIn : TaaWindowFilter;
- S : string;
- B : array [0..20] of byte; {21 byte buffer}
- BytesRead : longint;
- begin
- writeln('Testing buffered filters...');
-
- FSIn := nil;
- FSOut := nil;
- BFIn := nil;
- BFOut := nil;
- try
- FSIn := TFileStream.Create('AAStrms.pas', fmOpenRead);
- BFIn := TaaReadBufferFilter.Create(FSIn, -1);
- FSOut := TFileStream.Create('test1.tst', fmCreate);
- BFOut := TaaWriteBufferFilter.Create(FSOut);
-
- BytesRead := BFIn.Read(B, sizeof(B));
- while (BytesRead <> 0) do begin
- BFOut.Write(B, BytesRead);
- BytesRead := BFIn.Read(B, sizeof(B));
- end;
-
- finally
- BFOut.Free;
- FSOut.Free;
- BFIn.Free;
- FSIn.Free;
- end;
-
- writeln('Testing text and debug filters...');
-
- FSIn := nil;
- FSOut := nil;
- TFIn := nil;
- TFOut := nil;
- Debug := nil;
- try
- FSIn := TFileStream.Create('AAStrms.pas', fmOpenRead);
- Debug := TaaDebugFilter.Create(FSIn, 'test2.log');
- TFIn := TaaReadTextFilter.Create(Debug, -1);
- FSOut := TFileStream.Create('test2.tst', fmCreate);
- TFOut := TaaWriteTextFilter.Create(FSOut);
-
- while not TFIn.AtEndOfStream do begin
- S := TFIn.ReadLine;
- TFOut.WriteLine(S);
- end;
-
- finally
- TFIn.Free;
- Debug.Free;
- FSIn.Free;
- TFOut.Free;
- FSOut.Free;
- end;
-
-
- writeln('Testing regex filters...');
-
- FSIn := nil;
- RFIn := nil;
- try
- FSIn := TFileStream.Create('AAStrms.pas', fmOpenRead);
- RFIn := TaaRegexTextFilter.Create(FSIn, -1,
- '^(procedure|function)');
-
- while not RFIn.AtEndOfStream do begin
- S := RFIn.ReadLine;
- writeln(S);
- end;
-
- finally
- RFIn.Free;
- FSIn.Free;
- end;
-
- writeln('Testing window filter...');
-
- FSIn := nil;
- TFIn := nil;
- WFIn := nil;
- try
- FSIn := TFileStream.Create('AAStrms.pas', fmOpenRead);
- WFIn := TaaWindowFilter.Create(FSIn, 20000);
- TFIn := TaaReadTextFilter.Create(WFIn, -1);
-
- while not TFIn.AtEndOfStream do begin
- S := TFIn.ReadLine;
- writeln(S);
- end;
-
- finally
- TFIn.Free;
- WFIn.Free;
- FSIn.Free;
- end;
-
- writeln('Done');
- readln;
- end.
-